package ExtraDemo.demo02.mycountdownlatch;

import java.util.concurrent.CountDownLatch;

public class MyCountDownLatchDemo {
    public static void main(String[] args) {
        //1.创建CountDownLatch的对象，需要传递给四个线程
        //在底部就定义了一个计数器，此时计数器的值就是3
        CountDownLatch countDownLatch =new CountDownLatch(3);
        //2.创建四个线程对象并且开启他们
        MotherThread motherThread=new MotherThread(countDownLatch);
        motherThread.start();

        ChildThread1 childThread1=new ChildThread1(countDownLatch);
        childThread1.setName("小明");
        childThread1.start();
        ChildThread2 childThread2=new ChildThread2(countDownLatch);
        childThread2.setName("小刚");
        childThread2.start();
        ChildThread3 childThread3=new ChildThread3(countDownLatch);
        childThread3.setName("小花");
        childThread3.start();

    }
}
